/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2022/2/21
 * Time: 21:30
 * Description:
 */
class OuterClass2 {
    public int data1 = 1;
    public int data2 = 2;
    public static int data3 = 3;

    //静态内部类
    static class InnerClass2 {
        public int data1 = 1000;
        public int data4 = 4;
        private int data5 = 5;
        public static final int data6 = 6;//常量

//        public OuterClass2 out = new OuterClass2(); 第一种方案
        public OuterClass2 out;//第2中方案

        public InnerClass2() {

        }

        public InnerClass2(OuterClass2 out) {
            this.out = out;
        }

        public void test() {
            System.out.println(data1);
            System.out.println(out.data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("InnerClass2::test()");
        }
    }
}

public class TestDemo4 {
    public static void main(String[] args) {
        OuterClass2 out = new OuterClass2();
        OuterClass2.InnerClass2 innerClass2 = new OuterClass2.InnerClass2(out);

    }
    public static void main1(String[] args) {
        OuterClass2.InnerClass2 innerClass2 = new OuterClass2.InnerClass2();
        innerClass2.test();
    }
}
